<template>
    <div>
        <div>
            <van-form>

            <div v-for='(j,pindex) in list' :key='j'>
                    <van-field  :label="i.label+pindex" v-model='value[i.key+pindex]'  v-for='(i) in j' :key="i"/>
            </div>

            <van-button @click='add'>添加答案</van-button>
<!--             <van-button @click="add1">添加题目</van-button>-->
            <van-button @click='save'>提交</van-button>
            </van-form>
        </div>


    </div>
</template>
<script>
export default {
    name:"workinif",
    data(){
        return{
            form:{},
            list:[[{'label':'添加评估题目','key':'dopic'},{'label':'添加评估答案','key':'answer'}]],
            value:{},
            // id:this.$route.query.id,

        }
    },
    methods: {
        add(){
            this.list.push([{'label':'添加评估答案','key':'answer'}])
        },
        // add1(){
        //     this.list.push([{'label':'添加评估题目','key':'dopic'},{'label':'添加评估答案','key':'answer'}])
        //     this.number += 1
        // },
        save(){
            console.log(this.value);
            this.axios.post(`http://127.0.0.1:5000/addassess`,this.value).then(res=>{
                console.log(res);
                if(res.data.code==200){
                    alert("添加成功")
                }else{
                    alert("添加失败")
                }
            })

        },
    },
}
</script>
<style>

</style>
